#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const process = require('process');
const rootPath = process.cwd();
require('shelljs/global');
require('colors');
module.exports = function createJson (data, jsonPath) {
    // if (test('-f', jsonPath)) {
    //     echo(`重写文件:${jsonPath}`.blue);
    //     rm('-f', jsonPath);
    // }
    // touch(jsonPath);
    return new Promise ((resolve, reject) => {
        let jsonStr = JSON.stringify(data, '', 4);
        let status = fs.writeFile(jsonPath, jsonStr, 0, 'utf8', (err) => {
            if (err) {
                reject(err);
            } else {
                resolve();
            }
        });
    });
}
